fix: validate Contributors API response schema#532
Conversation
✅ Deploy Preview for github-spy ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
More reviews will be available in 24 minutes and 9 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe ChangesContributors API Validation and Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Improves the Contributors page’s resilience by adding response validation, richer error handling, and more informative error UI when the GitHub API request fails.
Changes:
- Added a custom error type + structured
FetchErrorstate for richer error handling. - Added runtime validation to ensure the API returns a
Contributor[]before rendering. - Expanded UI error messaging for rate limiting, 404, and timeout scenarios.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pages/Contributors/Contributors.tsx`:
- Around line 101-106: The error handling in the Contributors component
currently treats only HTTP 403 as a rate-limit; update the branch that checks
err.response?.status to treat 429 the same as 403 by checking for
(err.response?.status === 403 || err.response?.status === 429) and setting
fetchError.message to the rate-limit message, fetchError.isRateLimited = true,
and fetchError.statusCode to the actual status (403 or 429) for both occurrences
(the block using fetchError and the later similar branch around lines 112–114).
Ensure you adjust any message/context if you want to distinguish 429, otherwise
handle it identically to 403.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 72ff36c6-ae03-4e0d-bbbe-1d9df398d352
📒 Files selected for processing (1)
src/pages/Contributors/Contributors.tsx
|
hi @mehul-m-prajapati please review this pr whenever possible! |
|
🎉🎉 Thank you for your contribution! Your PR #532 has been merged! 🎉🎉 |
Related Issue
Description
Implemented runtime validation and improved error handling for the
ContributorsPagecomponent to prevent unsafe GitHub API responses from causing runtime failures.Changes made:
Added runtime type guard validation for
Contributor[]Added custom
ContributorsErrorclass for structured error handlingAdded validation for all required contributor fields
Improved Axios error handling using
axios.isAxiosErrorAdded handling for:
Prevented invalid API data from being assigned to state
Added improved fallback error UI and user feedback
This improves runtime safety, API resilience, and overall stability of the Contributors page.
How Has This Been Tested?
Screenshots (if applicable)
N/A
Type of Change
###Suggested Labels :
gssoc'26,gssoc:approved , type:fix , level:intermediate , quality:clean
Summary by CodeRabbit